package com.seventeen.monster.redisson.core;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author seventeen
 */
public class SleepUtils {
    private final static Logger log = LoggerFactory.getLogger(SleepUtils.class);

    /**
     * 使当前线程休眠指定的毫秒数。
     *
     * @param milliseconds 要休眠的毫秒数
     */
    public static void sleep(long milliseconds) {
        try {
            Thread.sleep(milliseconds);
        } catch (InterruptedException e) {
            // 处理中断异常，恢复中断状态
            Thread.currentThread().interrupt();
            log.error("线程休眠被中断:{}", e.getMessage());
        }
    }

    /**
     * 以秒为单位使当前线程休眠。
     *
     * @param seconds 要休眠的秒数
     */
    public static void sleepSeconds(long seconds) {
        sleep(seconds * 1000);
    }
}